{{#section 'style'}}<link rel="stylesheet" href="/style/book.css">{{/section}}


<div class="techbook bookDetail">
    <!--head-->
    {{> header_list}}
    <!--head End-->

    <!--body-->
    <div class="body">
        <div class="wrap">
            <div class="crumbs">
                <div class="con">
                    <a href="/">首页</a><i>&gt;</i><b>图书详细页</b>
                </div>
            </div>

            <div class="bookDetailBox bgWhite">

                <dl class="toggle fl" id="toggle">
                    <dt><img src="{{imagesCDN}}/previews/{{preview}}"/></dt>
                    <dd>
                        <div class="list">
                            <ul>
                                {{#each previewnames}}
                                    <li{{#if @first}} class="curr"{{/if}} data-img="{{../imagesCDN}}/previews/{{this}}">
                                        <img src="{{../imagesCDN}}/thumbs/{{lookup ../thumbnames @index}}" alt=""/>
                                    </li>
                                {{/each}}
                            </ul>
                        </div>
                    </dd>
                    <div class="bot"><span>商品编号：{{book.sku}}</span><a href="">举报</a></div>
                </dl>

                <div class="right fr">
                    <h2>{{book.name}}</h2>
                    {{#if book.subTitle}}
                    <p class="sub">{{book.subTitle}}</p>
                    {{/if}}
                    {{#if book.author}}
                    <p class="author">作者：{{{book.author}}}</p>
                    {{/if}}
                    <div class="price">
                        <div class="fl">
                            <span>价格：</span>
                            <b>￥{{book.price}}</b>
                            <i>{{book.discount}}折</i>
                            <em>原价：<s>￥{{book.market}}</s>元</em>
                        </div>
                        <p class="fr">累计评价：<b>{{comment.commentCountStr}}</b> 条</p>
                    </div>

                    <div class="yf">
                        <em>运费：</em>
                        <span>北京</span>
                        <span>&nbsp;至&nbsp;</span>
                        <dl class="to">
                            <dt>武汉</dt>
                            <dd>
                                <i class="close">&times;</i>
                                <div class="zxs">
                                    <span>北京</span><span>北京</span><span>北京</span><span>北京</span>
                                    <div class="cities">
                                        <span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span><span>武汉</span>
                                    </div>
                                </div>
                            </dd>
                        </dl>
                        <span class="total">快递费：10.00元</span>
                    </div>

                    <dl class="qty">
                        <dt>数量：</dt>
                        <dd id="qty" data-limit="5">
                            <span class="cut">-</span>
                            <input type="text" class="val" value="1"/>
                            <span class="add">+</span>
                            <i>库存85件</i>
                        </dd>
                    </dl>

                    <div class="btns">
                        <span class="addCart" data-addCart="{{imagesCDN}}/previews/{{preview}}" data-sku="{{book.sku}}">加入购物车</span>
                        {{#if favorite}}
                            <span class="favorite">已收藏</span>
                        {{else}}
                            <span class="favorite" data-sku="{{book.sku}}" data-user_id="{{user._id}}">收藏</span>
                        {{/if}}
                    </div>

                    <dl class="service">
                        <dt>服务承诺：</dt>
                        <dd>
                            <span class="seven">7天无理由退货</span>
                            <span class="th">退货补运费</span>
                        </dd>
                    </dl>

                    <dl class="pay">
                        <dt>支付方式：</dt>
                        <dd></dd>
                    </dl>

                </div>

            </div>

            <div class="bookDetailSide bookSide fl">
                <dl class="bookDetailShopInfo bgWhite">
                    <dt>店铺信息</dt>
                    <dd>
                        <div class="face"><div class="img"><a href=""><img src="/img/example/shop_face.gif" alt=""/></a></div></div>
                        <h3><a href="">多点子书箱精品</a></h3>
                        <ul class="score">
                            <li><em>商品质量：</em><span class="low">4.4</span><i class="high">高</i><span class="low">3.2%</span></li>
                            <li><em>物流速度：</em><span class="high">4.5</span><i class="low">低</i><span class="high">3.2%</span></li>
                            <li><em>物流速度：</em><span class="high">4.5</span><i class="low">低</i><span class="high">3.2%</span></li>
                        </ul>
                    </dd>
                </dl>

                <dl class="sameBookTopN bookDetailSideDL bgWhite">
                    <dt>同类图书排行</dt>
                    <dd>
                        <div class="sameBookTopNTab tab">
                            <div class="tabs">
                                <ul class="list">
                                    <li class="tab tabCurr">畅销榜</li>
                                    <li class="tab">新书榜</li>
                                </ul>
                            </div>
                            <div class="tabCons">
                                <div class="tabCon tabConCurr">

                                    <div class="sideBookList fl">
                                        <dl class="hl">
                                            <dt class="hot">1</dt>
                                            <dd>
                                                <dl class="book">
                                                    <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">2</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">3</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">4</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">5</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">6</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">7</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>
                <dl>
                    <dt class="hot">8</dt>
                    <dd>
                        <dl class="book">
                            <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
                    <dd>
                        <div><a href="">11全国计算机等级考试二级全国计算机等级考试二级END</a></div>
                        <b>￥21.00</b>
                        <p>￥35.00</p>
                    </dd>
                </dl>
                </dd>
                </dl>

            </div>

        </div>
        <div class="tabCon">Con-2</div>
    </div>
</div>
</dd>
</dl>

<dl class="bookDetailSideDL mt20 bgWhite">
    <dt>您的浏览历史</dt>
    <dd>
        <div class="bookDetailHistory">

            <dl>
                <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
    <dd>
        <div><a href="">全国计算机等级考试二级全国计算机等级考试二级END</a></div>
        <p><b>￥21.00</b><s>￥35.00</s></p>
    </dd>
</dl>
<dl>
    <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
    <dd>
        <div><a href="">全国计算机等级考试二级全国计算机等级考试二级END</a></div>
        <p><b>￥21.00</b><s>￥35.00</s></p>
    </dd>
</dl>
<dl>
    <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
    <dd>
        <div><a href="">全国计算机等级考试二级全国计算机等级考试二级END</a></div>
        <p><b>￥21.00</b><s>￥35.00</s></p>
    </dd>
</dl>
<dl>
    <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
    <dd>
        <div><a href="">全国计算机等级考试二级全国计算机等级考试二级END</a></div>
        <p><b>￥21.00</b><s>￥35.00</s></p>
    </dd>
</dl>
<dl>
    <dt><div class="img"><a href=""><img src="/img/example/first_book.jpg" alt=""/></a></div></dt>
    <dd>
        <div><a href="">全国计算机等级考试二级全国计算机等级考试二级END</a></div>
        <p><b>￥21.00</b><s>￥35.00</s></p>
    </dd>
</dl>

</div>

</dd>

</dl>

</div>

<div class="bookDetailInfo bookDet bgWhite mt20 fr">
    <div class="bookCommentTab tab">
        <div class="tabs" id="bookCommentTabTabs">
            <ul class="list">
                <li class="tab tabCurr"><div>商品详情</div><p></p></li>
                <li class="tab"><div>累计评价<em>{{comment.commentCountStr}}</em></div><p></p></li>
            </ul>
        </div>
        <div class="tabCons">
            <div class="tabCon tabConCurr bookCommentGoods">

                <ul class="bookCommentInfo">
                    {{#if book.param.publishing}}<li>出版社：{{book.param.publishing}}</li>{{/if}}
                    {{#if book.param.isbn}}<li>ISBN：{{book.param.isbn}}</li>{{/if}}
                    {{#if book.param.version}}<li>版次：{{book.param.version}}</li>{{/if}}
                    {{#if book.param.code}}<li>商品编码：{{book.param.code}}</li>{{/if}}
                    {{#if book.param.pack}}<li>包装：{{book.param.pack}}</li>{{/if}}
                    {{#if book.param.size}}<li>开本：{{book.param.size}}</li>{{/if}}
                    {{#if book.param.time}}<li>出版时间：{{book.param.time}}</li>{{/if}}
                    {{#if book.param.paper}}<li>用纸：{{book.param.paper}}</li>{{/if}}
                    {{#if book.param.page}}<li>页数：{{book.param.page}}</li>{{/if}}
                </ul>


                {{#if book.detail.bjtj}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>编辑推荐</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.bjtj}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}

                {{#if book.detail.nrjj}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>内容简介</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.nrjj}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}


                {{#if book.detail.zzjj}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>作者简介</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.zzjj}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}

                {{#if book.detail.jcsz}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>精彩书评</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.jcsz}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}

                {{#if book.detail.ml}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>目录</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.ml}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}

                {{#if book.detail.jcsz}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>精彩书摘</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.jcsz}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}

                {{#if book.detail.qy}}
                    <dl class="bookCommentGoodsDL">
                        <dt><b>前言/序言</b></dt>
                        <dd>
                            <div class="text">
                                {{{book.detail.qy}}}
                            </div>
                        </dd>
                    </dl>
                {{/if}}


                <dl class="bookCommentGoodsDL">
                    <dd class="bookDirectory">
                        <div class="tip">
                            <dl>
                                <dt>安全提示：</dt>
                                <dd>11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END。</dd>
                            </dl>
                            <dl>
                                <dt>内容声明：</dt>
                                <dd>11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END。11全国计算机等级考试二级全国计算机等级考试二级END</dd>
                            </dl>
                        </div>
                    </dd>
                </dl>

            </div>

            <div class="tabCon bookCommentList">

                <div class="scoreBox">
                    <div class="rate fl">
                        <strong>{{comment.goodRateStr}}</strong><i>%</i>
                        <p>好评度</p>
                    </div>
                    <ul class="percent">
                        <li>
                            <span>好评({{comment.goodRateStr}}%)</span>
                            <div><p style="width:{{comment.goodRateStr}}%;"></p></div>
                            <p>&emsp;({{comment.goodCount}}/{{comment.commentCount}})</p>
                        </li>
                        <li>
                            <span>中评({{comment.generalRateStr}}%)</span>
                            <div><p style="width:{{comment.generalRateStr}}%;"></p></div>
                            <p>&emsp;({{comment.generalCount}}/{{comment.commentCount}})</p>
                        </li>
                        <li>
                            <span>差评({{comment.badRateStr}}%)</span>
                            <div><p style="width:{{comment.badRateStr}}%;"></p></div>
                            <p>&emsp;({{comment.badCount}}/{{comment.commentCount}})</p>
                        </li>
                    </ul>
                </div>

                <div class="bookCommentListTab tab">
                    <div class="tabs">
                        <div class="list">
                            <label class="tab"><input type="radio" checked name="type"/><span>全部</span></label>
                            <label class="tab"><input type="radio" name="type"/><span>图片</span></label>
                        </div>
                    </div>
                    <div class="tabCons">
                        <div class="tabCon tabConCurr bookCommentListTabCon">
                            {{#each comment.comments as |c|}}
                                <div class="item">
                                    <div class="user fr"><p class="nick"><span>{{c.nick}}</span>(匿名)</p><p class="lv">VIP1</p></div>

                                    <div class="det">
                                        <div class="comment">{{{c.content}}}</div>
                                        <div class="bookCommentListTabImg">
                                            {{#if c.images.length}}
                                                <ul class="thumb">
                                                    {{#each c.smalls}}
                                                    <li><div><img src="{{../../imagesCDN}}/comments/{{.}}" alt=""/></div></li>
                                                    {{/each}}
                                                </ul>
                                                <ul class="big">
                                                    {{#each c.bigs}}
                                                        <li><div><img src="{{../../imagesCDN}}/comments/{{.}}" alt=""/></div></li>
                                                    {{/each}}
                                                </ul>
                                            {{/if}}
                                        </div>
                                        <p class="time">{{c.time}}</p>
                                    </div>

                                </div>
                            {{/each}}

                            <div class="page">
                                <div>
                                    <a class="prev disabled">上一页</a><a class="curr">1</a><a>2</a><span>...</span><a>3</a><a>4</a><a>5</a><a class="next">下一页</a>
                                </div>
                            </div>


                        </div>
                        <div class="tabCon bookCommentListTabCon">2</div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

<div class="cb"></div>


</div>
</div>
    <!--body End-->

    <!--foot-->
    {{>footer}}
    <!--foot End-->

    <!--sideBar-->
    <div class="sideBox" id="sideBox">
        <div class="sideBar" id="sideBar">
            <div class="ad"><a href=""><img src="/img/example/sideBar_ad.jpg" alt=""/></a></div>

            <dl class="ewm">
                <dt class="icon"></dt>
                <dd>
                    <img src="/img/example/sideBar_ewm.gif"/>
                    <p>首单立减5元</p>
                </dd>
            </dl>

            <div class="cart" id="cartEnd">
                <div class="icon"><i>0</i></div>
                <div>购物车</div>
                <p>6</p>
            </div>

            <div class="bot">
                <dl class="sc animation" onclick="AddFavorite();">
                    <dt class="icon"></dt>
                    <dd>收藏页面</dd>
                </dl>
                <dl class="mine animation">
                    <dt class="icon"></dt>
                    <dd>我的收藏</dd>
                </dl>

                <dl class="backTop" id="backTop">
                    <dt class="icon"></dt>
                </dl>

                <dl class="fk">
                    <dt>意见反馈</dt>
                </dl>

            </div>
        </div>

        <div class="sideCart" id="sideCart">
            <!--            <div class="no_data">您还没有选购商品，快去选购吧！</div>-->

            <div class="top"><label><input type="checkbox" class="chkAll" checked/><em>全选</em></label><a href="">全屏查看</a></div>

            <dl class="list">
                <dd data-cartId="">
                    <input type="checkbox" checked class="chk"/>
                    <div class="img"><a href=""><img src="/img/example/book_99x99.jpg" alt=""/></a></div>
                    <div class="price">￥<b>100.00</b></div>
                    <div class="qty" data-limit="5"><i class="cut disabled">-</i><span>1</span><i class="add">+</i></div>
                    <div class="total">￥<b>100.00</b></div>
                    <i class="del">&times;</i>
                </dd>
                <dd data-cartId="">
                    <input type="checkbox" checked class="chk"/>
                    <div class="img"><a href=""><img src="/img/example/book_99x99.jpg" alt=""/></a></div>
                    <div class="price">￥<b>100.00</b></div>
                    <div class="qty" data-limit="5"><i class="cut">-</i><span>5</span><i class="add disabled">+</i></div>
                    <div class="total">￥<b>500.00</b></div>
                    <i class="del">&times;</i>
                </dd>
            </dl>

            <div class="bot">
                <div class="total">
                    <span>已选<b>2</b>件</span>
                    <em>￥<b>300.00</b></em>
                </div>
                <div class="btn">结算</div>
            </div>

        </div>

    </div>
    <!--sideBar End-->

</div>

{{#section 'script'}}
    <script src="/script/jquery.fly.min.js"></script>
    <script>
    $(function(){
        //Tab
        $('.tab').tab();

        //图书图片切换
        ;(function(){
            var $box=$('#toggle'),$img=$box.find('dt>img');
            $box.on('click','.list li', function () {
                $(this).addClass('curr').siblings().removeClass('curr');
                $img.attr('src',$(this).attr('data-img'));
            });
        })();

        //购买数量调整
        ;(function () {
            var validate= function (val) {
                return /$\d+^/.test(val);
            };
            var $qty=$('#qty'),$val=$qty.find('.val'),limit=parseInt($qty.attr('data-limit'));
            $val.on('keyup', function () {
                var val=$(this).val();
                if(!validate(val)){
                    val=val.replace(/\D/g,'').trim();
                    if(''==val){
                        val=1;
                    }
                    $(this).val(val);
                }else{
                    if(parseInt(val)>limit){
                        $(this).val(limit);
                    }
                }
            });

            $qty.on('click','.cut', function () {
                var val=$val.val();
                val--;
                if(!~val)return;
                $val.val(val);
            });

            $qty.on('click','.add', function () {
                var val=$val.val();
                val++;
                if(val>limit)return;
                $val.val(val);
            });
        })();

        //楼层左侧TopN书籍Toggle
        $('.sideBookList').sideBookListToggle();

        //评论图片切换
        $('.bookCommentListTabImg').commentListImgToggle();

        //加入购物车
        ;(function(){
            var $qty=$('#qty').find('.val'),timer;
            if(timer)return;
            $('.addCart').one('click', function () {
                var $this=$(this),$cartEnd = $('#cartEnd'),$icon=$cartEnd.find('.icon'),$total=$cartEnd.find('p'), $flyer = $('<img class="addCartFlyer" src="'+$(this).attr('data-addCart')+'"/>');
                var startOffset=$(this).offset(),endOffset=$icon.offset(),st=$(window).scrollTop();
                $flyer.fly({
                    start: {
                        left: startOffset.left+50,
                        top: startOffset.top-st-10
                    },
                    end: {
                        left: endOffset.left+4,
                        top: endOffset.top+4-st,
                        width: 20,
                        height: 20
                    },
                    speed:2,
                    onEnd: function () {
                        $flyer.fadeOut(function () {
                            var val=parseInt($qty.val())|0;
                            $icon.find('i').text(val).stop().show().animate({
                                top:-10,
                                opacity:0
                            }, function () {
                                $(this).hide().css({
                                    top:0,
                                    opacity:1
                                });
                                var qty=parseInt($total.text())||0;
                                qty+=val;
                                if(qty>99)qty='99+';
                                $total.text(qty);
                                $this.text('已加入购物车').addClass('yet');
                            });
                        });
                    }
                });
            });
        })();

        //整个侧边栏
        ;(function(){
            var $sideBar=$('#sideBar'),$sideBox=$('#sideBox');

            //动画
            $sideBar.on('click','.cart',function () {
                if($(this).hasClass('open')){
                    $(this).removeClass('open');
                    $sideBox.animate({
                        right:-320
                    },500);
                }else{
                    $(this).addClass('open');
                    $sideBox.animate({
                        right:0
                    },500);
                }
            });

            //底部小功能
            $sideBar.on({
                mouseenter: function () {
                    $(this).find('dd').show().animate({
                        left:-89
                    });
                },
                mouseleave: function () {
                    $(this).find('dd').stop().hide().css('left',0);
                }
            },'.animation');

            //返回顶部
            $('#backTop').click(function(){
                $("html,body").animate({"scrollTop":"0"},500);
            });
        })();

        //购物车
        ;(function(){
            var $sideCart=$('#sideCart'),$list=$('.list',$sideCart),$chkAll=$('.chkAll',$sideCart),$bot=$('.bot',$sideCart);

            $list.find('dd').each(function(i,dd){
                var $dd=$(dd);

                //删除
                $dd.on('click','.del', function () {
                    $dd.remove();
                    updateTotal();
                });
                //单个选中
                $dd.on('click','.chk', function () {
                    var checked=this.checked;
                    if(checked){
                        if(getChkLength()==$list.find('dd').length){
                            toggleAll(checked);
                        }
                    }else{
                        $chkAll.prop('checked',checked);
                        if(0==getChkLength()){
                            toggleAll(false);
                        }
                    }
                    updateTotal();
                });
                //全选
                $chkAll.on('click', function () {
                    toggleAll(this.checked);
                    updateTotal();
                });
                //数量调整
                var price=parseInt($dd.find('.price>b').text())||0,$num=$dd.find('.qty span'),limit=parseInt($dd.find('.qty').data('limit'))||0;
                $dd.on('click','.add', function () {
                    if($(this).hasClass('disabled'))return;
                    var num=parseInt($num.text())||0;
                    num++;
                    if(num>1)$dd.find('.cut').removeClass('disabled');
                    if(num>=limit)$(this).addClass('disabled');
                    $num.text(num);
                    $dd.find('.total b').text((price*num).toFixed(2));
                    updateTotal();
                });
                $dd.on('click','.cut', function () {
                    if($(this).hasClass('disabled'))return;
                    var num=parseInt($num.text())||0;
                    num--;
                    if(num<=limit)$dd.find('.add').removeClass('disabled');
                    if(num<=1)$(this).addClass('disabled');
                    $num.text(num);
                    $dd.find('.total b').text((price*num).toFixed(2));
                    updateTotal();
                });
            });

            function toggleAll(checked){
                $chkAll.prop('checked',checked);
                $list.find('dd .chk').prop('checked',checked);
                updateTotal();
            }

            function getChkLength(){
                var chk=0;
                $list.find('dd').each(function (i, dd) {
                    if($(dd).find('.chk').prop('checked')){
                        chk++;
                    }
                });
                return chk;
            }

            function updateTotal(){
                var qty=0,total=0;
                $list.find('dd').each(function (i, dd) {
                    if($(dd).find('.chk').prop('checked')){
                        qty+=parseInt($(dd).find('.qty>span').text())||0;
                        total+=parseInt($(dd).find('.total>b').text())||0;
                    }
                });
                $bot.find('.total>span>b').text(qty);
                $bot.find('.total>em>b').text(total.toFixed(2));
                $('.btn',$bot)[(qty&&total?'remove':'add')+'Class']('disabled');
            }
        })();

        //收藏商品
        ;(function(){
            $('.favorite').one('click', function () {
                var sku=$(this).data('sku'),user_id=$(this).data('user_id');
                if(!sku || !user_id)return;
                $(this).text('已收藏');
                $.ajax({
                    url:'/ucenter/favorite',
                    type:'POST',
                    data:{
                        user_id:'{{user._id}}',
                        userName:'{{user.name}}',
                        sku:sku,
                        bookTitle:$(this).closest('.fr').find('h2').eq(0).text()
                    },
                    success: function (data) {
                        console.log('succ:',data);
                    },
                    error: function (e) {
                        console.log('err:',e);
                    }
                });
            });
        })();


        //固定
        ;(function(){
            var $tabs=$('#bookCommentTabTabs'),timer;
            $(window).on('scroll', function () {
                clearTimeout(timer);
                timer=setTimeout(function () {
                    $tabs[($(window).scrollTop()>815?'add':'remove')+'Class']('fix');
                });
            });
        })();
    });
</script>
{{/section}}